package com.lemurian.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Type;

import com.lemurian.entity.utils.DefaultPersistence;

@Entity
@Table(name="tb_client")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@BatchSize(size=10000)
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class Client extends DefaultPersistence implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Column(length=1,name="is_approved", nullable=true)
	@Type(type="true_false")
	private Boolean approved;
	
	private Boolean clientStatus;
	private Date checkDate;
	private String agentProperty;
	
	private Date inClientDate;
	private String tbo;
	private String documentLocation;
	private String remarks;
	private String pendingRemarks;
	private Integer acceptedStatus;
	
	@Column(length=1,name="is_PT", nullable=true)
	@Type(type="true_false")
	private Boolean isPT;
	
	@ManyToOne()
	@JoinColumn(name="debitur_id")
	private Debitur debitur;
	
	@ManyToOne()
	@JoinColumn(name="seller_id")
	private Seller seller;
	
	@ManyToOne()
	@JoinColumn(name="account_officer_id")
	private User accountOfficer;
	
	@ManyToOne()
	@JoinColumn(name="marketing_head_id")
	private User marketingHead;
	
	@ManyToOne()
	@JoinColumn(name="officer_type_id")
	private User officerType;
	
	@ManyToOne()
	@JoinColumn(name="bank_id")
	private Category bank;
	
	@ManyToOne()
	@JoinColumn(name="department_id")
	private Category department;
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "client")
	private Set<Tax> taxes;
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "client")
	private Set<SignatureSchedule> signatureSchedules;
	
	@OneToMany(mappedBy="client", fetch=FetchType.LAZY)
	private List<ClientCertificate> clientCertificates;
	
	@OneToMany(mappedBy="client", fetch=FetchType.LAZY)
	private List<ManagementClientType> managementClientTypes;
	
	@OneToMany(mappedBy="client", fetch=FetchType.LAZY)
	private List<ClientDocument> clientDocuments;
	
	@OneToMany(mappedBy="client", fetch=FetchType.LAZY)
	private List<Management> managements;
	
	public User getAccountOfficer() {
		return accountOfficer;
	}
	
	public void setAccountOfficer(User accountOfficer) {
		this.accountOfficer = accountOfficer;
	}

	public Debitur getDebitur() {
		return debitur;
	}

	public void setDebitur(Debitur debitur) {
		this.debitur = debitur;
	}

	public Seller getSeller() {
		return seller;
	}

	public void setSeller(Seller seller) {
		this.seller = seller;
	}

	public User getMarketingHead() {
		return marketingHead;
	}

	public void setMarketingHead(User marketingHead) {
		this.marketingHead = marketingHead;
	}

	public User getOfficerType() {
		return officerType;
	}

	public void setOfficerType(User officerType) {
		this.officerType = officerType;
	}

	@Column(length=1,name="client_status", nullable=true)
	@Type(type="true_false")
	public Boolean getClientStatus() {
		return clientStatus;
	}

	public void setClientStatus(Boolean clientStatus) {
		this.clientStatus = clientStatus;
	}

	@Temporal(TemporalType.DATE)
	@JoinColumn(name="check_date")
	public Date getCheckDate() {
		return checkDate;
	}

	public void setCheckDate(Date checkDate) {
		this.checkDate = checkDate;
	}

	@Column(name="agent_property", length=45)
	public String getAgentProperty() {
		return agentProperty;
	}

	public void setAgentProperty(String agentProperty) {
		this.agentProperty = agentProperty;
	}

	public Category getBank() {
		return bank;
	}

	public void setBank(Category bank) {
		this.bank = bank;
	}

	@Temporal(TemporalType.DATE)
	@JoinColumn(name="in_client_date")
	public Date getInClientDate() {
		return inClientDate;
	}

	public void setInClientDate(Date inClientDate) {
		this.inClientDate = inClientDate;
	}

	@Column(name="tbo", length=45)
	public String getTbo() {
		return tbo;
	}

	public void setTbo(String tbo) {
		this.tbo = tbo;
	}

	@Column(name="document_location", length=45)
	public String getDocumentLocation() {
		return documentLocation;
	}

	public void setDocumentLocation(String documentLocation) {
		this.documentLocation = documentLocation;
	}

	public Category getDepartment() {
		return department;
	}

	public void setDepartment(Category department) {
		this.department = department;
	}

	public Set<Tax> getTaxes() {
		return taxes;
	}

	public void setTaxes(Set<Tax> taxes) {
		this.taxes = taxes;
	}

	public Set<SignatureSchedule> getSignatureSchedules() {
		return signatureSchedules;
	}

	public void setSignatureSchedules(Set<SignatureSchedule> signatureSchedules) {
		this.signatureSchedules = signatureSchedules;
	}

	public List<ClientCertificate> getClientCertificates() {
		return clientCertificates;
	}

	public void setClientCertificates(List<ClientCertificate> clientCertificates) {
		this.clientCertificates = clientCertificates;
	}

	public List<Management> getManagements() {
		return managements;
	}

	public void setManagements(List<Management> managements) {
		this.managements = managements;
	}
	
	public Boolean getApproved() {
		return approved;
	}

	public void setApproved(Boolean approved) {
		this.approved = approved;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public List<ManagementClientType> getManagementClientTypes() {
		return managementClientTypes;
	}

	public void setManagementClientTypes(List<ManagementClientType> managementClientTypes) {
		this.managementClientTypes = managementClientTypes;
	}

	public List<ClientDocument> getClientDocuments() {
		return clientDocuments;
	}

	public void setClientDocuments(List<ClientDocument> clientDocuments) {
		this.clientDocuments = clientDocuments;
	}

	public Boolean getIsPT() {
		return isPT;
	}

	public void setIsPT(Boolean isPT) {
		this.isPT = isPT;
	}

	@Column(name="tbo", length=255)
	public String getPendingRemarks() {
		return pendingRemarks;
	}

	public void setPendingRemarks(String pendingRemarks) {
		this.pendingRemarks = pendingRemarks;
	}

	public Integer getAcceptedStatus() {
		return acceptedStatus;
	}

	public void setAcceptedStatus(Integer acceptedStatus) {
		this.acceptedStatus = acceptedStatus;
	}
}
